package com.cskaoyan.wordmemorize.controller.app;

import com.cskaoyan.wordmemorize.auth.StpKit;
import com.cskaoyan.wordmemorize.common.result.Result;
import com.cskaoyan.wordmemorize.dto.admin.PageDTO;
import com.cskaoyan.wordmemorize.dto.admin.VocDTO;
import com.cskaoyan.wordmemorize.dto.app.DisplayBookVocDTO;
import com.cskaoyan.wordmemorize.dto.app.DisplayChapterDTO;
import com.cskaoyan.wordmemorize.request.AppVocPageRequest;
import com.cskaoyan.wordmemorize.service.VocService;
import jakarta.annotation.Resource;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

// todo 【移动端-单词模块】

@RestController
@RequestMapping("user/voc")
public class UserVocController {

    @Resource
    VocService vocService;

    // todo 查看单词详情
    @GetMapping("detail/{vocId}")
    public Result<VocDTO> getVocDetail(@PathVariable Long vocId) {
        long userId = StpKit.USER.getLoginIdAsLong();
        VocDTO vocDetail = vocService.getVocDetail(vocId, userId);
        return Result.ok(vocDetail);
    }

    // todo 获取书籍单词列表(无章节版)
    @GetMapping("book/display")
    public Result<PageDTO<DisplayBookVocDTO>> getDisplayBookVocsInfo(AppVocPageRequest pageRequest) {
        String userId = StpKit.USER.getLoginIdAsString();
        pageRequest.setUserId(userId);
        PageDTO<DisplayBookVocDTO> displayBookVocsInfo = vocService.getDisplayBookVocsInfo(pageRequest);
        return Result.ok(displayBookVocsInfo);
    }

    // todo 获取书籍单词列表(有章节版)
    @GetMapping("/book/chapter/display")
    public Result<PageDTO<DisplayChapterDTO>> getDisplayBookChapterVocsInfo(AppVocPageRequest pageRequest) {
        String userId = StpKit.USER.getLoginIdAsString();
        pageRequest.setUserId(userId);
        PageDTO<DisplayChapterDTO> displayBookChapterVocsInfo = vocService.getDisplayBookChapterVocsInfo(pageRequest);
        return Result.ok(displayBookChapterVocsInfo);
    }

}
